import request from '@/utils/request'

// 项目列表
export function getAllProject(params) {
  return request({
    url: `/xm/project/info/getAllProject`,
    method: 'get',
    params,
    jy: true
  })
}

/************************************* 经费管理 *************************************** */

// 获取项目所有实施阶段
export function getProjectPeriod(params) {
  return request({
    url: `/xm/project/period/getProjectPeriod`,
    method: 'get',
    params,
    jy: true
  })
}

// 获取实施阶段成果内容
export function getPeriodDetails(params) {
  return request({
    url: `/xm/project/period/getPeriodDetails`,
    method: 'get',
    params,
    jy: true
  })
}

// 根据实施阶段ID获取阶段详情接口
export function getPeriodInfoById(params) {
  return request({
    url: `/xm/project/period/getPeriodInfoById/${params.periodId}`,
    method: 'get',
    params,
    jy: true
  })
}

// 提交阶段成果
export function submitPeriod(data) {
  return request({
    url: `/xm/project/period/submitPeriodDetails`,
    method: 'post',
    data,
    jy: true
  })
}

// 查看成果详情
export function getPeriodDetail(params) {
  return request({
    url: `/xm/project/period/getDetails/${params.periodDetailsId}`,
    method: 'get',
    params,
    jy: true
  })
}

// 删除成果内容
export function deletePeriod(params) {
  return request({
    url: `/xm/project/period/delete/${params.ids}`,
    method: 'delete',
    params,
    jy: true
  })
}

// 成果审核,0 通过 1 驳回
// 审核结果 approveResult 0,1; 阶段ID period; periodDetailsId
export function apiResultReview(params) {
  return request({
    url: `/xm/project/period/approvePeriodDetails`,
    method: 'post',
    params,
    jy: true
  })
}

/************************************* 经费管理 *************************************** */

// 经费列表
export function getFundsList(params) {
  return request({
    url: `/xm/project/funds/details/fundsList`,
    method: 'get',
    params,
    jy: true
  })
}

// 项目整体经费使用情况
export function projectFundsInfo(params) {
  return request({
    url: `/xm/project/funds/details/projectFundsInfo`,
    method: 'get',
    params,
    jy: true
  })
}

// 经费登记
export function addFundDetail(data) {
  return request({
    url: `/xm/project/funds/details/addFundsDetails`,
    method: 'post',
    data,
    jy: true
  })
}

// 登记科目列表
export function getSubjectList(params) {
  return request({
    url: `/xm/project/funds/details/getSubjectList`,
    method: 'get',
    params,
    jy: true
  })
}

// 项目经费详情列表
export function projectFundsDetailsList(params) {
  return request({
    url: `/xm/project/funds/details/projectFundsDetailsList`,
    method: 'get',
    params,
    jy: true
  })
}

// 经费报销列表
export function reimbursementPage(params) {
  return request({
    url: `/xm/project/funds/details/reimbursementPage`,
    method: 'get',
    params,
    jy: true
  })
}

// 登记报销费用
export function saveReimbursement(data) {
  return request({
    url: `/xm/project/funds/details/saveReimbursement`,
    method: 'post',
    data,
    jy: true
  })
}

// 撤销报销
export function cancelReimbursement(data) {
  return request({
    url: `/xm/project/funds/details/cancelReimbursement/${data.reimburseId}`,
    method: 'post',
    data,
    jy: true
  })
}

// 经费报销待审核列表
export function todoReimbursement(params) {
  return request({
    url: `/xm/project/funds/details/todoReimbursement`,
    method: 'get',
    params,
    jy: true
  })
}

// 经费报销审核
export function approveReimbursement(data) {
  return request({
    url: `/xm/project/funds/details/approveReimbursement`,
    method: 'post',
    data,
    jy: true
  })
}

// 打印经费报销
export function printReimbursement(params) {
  return request({
    url: `/xm/project/funds/details/printReimbursement/${params.id}`,
    method: 'get',
    params,
    jy: true
  })
}

/************************************* 资料管理 *************************************** */

// 获取资料文件夹树结构
export function getTreeNode(params) {
  return request({
    url: `/xm/project/document/tree`,
    method: 'get',
    params,
    jy: true
  })
}

// 根据文件夹ID获取文件夹下的内容
export function getChildrenNode(params) {
  return request({
    url: `/xm/project/document/getDocumentByParentId/${params.id}`,
    params,
    method: 'get',
    jy: true
  })
}

// 根据文件夹ID获取文件夹下的内容
export function getChildrenTreeNode(params) {
  return request({
    url: `/xm/project/document/getDocumentTreeByParentId/${params.id}`,
    params,
    method: 'get',
    jy: true
  })
}

// 根据文件名搜索文件
export function getDocumentByName(params) {
  return request({
    url: `/xm/project/document/getDocumentByName`,
    params,
    method: 'get',
    jy: true
  })
}

// 移动-更新文件或者文件夹
export function updateDocument(data) {
  return request({
    url: `/xm/project/document/updateDocument`,
    method: 'put',
    data,
    jy: true
  })
}

// 创建-上传文件或者文件夹
export function uploadOrBuildDocument(data) {
  return request({
    url: `/xm/project/document/uploadOrBuildDocument`,
    method: 'post',
    data,
    jy: true
  })
}

// 下载文件或者文件夹
export function downFileOrFolder(id) {
  return request({
    url: `/xm/project/document/downFileOrFolder/${id}`,
    method: 'get',
    jy: true
  })
}

// 删除文件或者文件夹
export function deleteDocument(id) {
  return request({
    url: `/xm/project/document/deleteDocument/${id}`,
    method: 'delete',
    jy: true
  })
}

// 快捷打印
export function printDocument(ids) {
  return request({
    url: `/xm/project/document/printDocument/${ids}`,
    method: 'get',
    jy: true
  })
}

// 批量下载
export function batchDownLoad(data) {
  return request({
    url: `/xm/project/document/batchDownLoad`,
    method: 'post',
    data,
    jy: true
  })
}
/************************************* 项目变更 *************************************** */

// 项目变更列表
export function getChangePage(params) {
  return request({
    url: `/xm/project/change/page`,
    method: 'get',
    params,
    jy: true
  })
}

// 变更类型列表
export function typeList() {
  return request({
    url: `/xm/project/change/typeList`,
    method: 'get',
    jy: true
  })
}

// 撤销变更
export function cancelChange(data) {
  return request({
    url: `/xm/project/change/cancelChange/${data.changeId}`,
    method: 'post',
    data,
    jy: true
  })
}

// 获取变更详情
export function getDetails(params) {
  return request({
    url: `/xm/project/change/getDetails/${params.changeId}`,
    method: 'get',
    params,
    jy: true
  })
}

// 更新变更申请
export function updateProjectChange(data) {
  return request({
    url: `/xm/project/change/updateChange`,
    method: 'put',
    data,
    jy: true
  })
}

// 提交变更申请
export function submitProjectChange(data) {
  return request({
    url: `/xm/project/change/submitProjectChange`,
    method: 'post',
    data,
    jy: true
  })
}

// 审核变更申请
export function approveChange(data) {
  return request({
    url: `/xm/project/change/approveChange`,
    method: 'post',
    data,
    jy: true
  })
}

// 管理员暂停终止项目
export function apiStopProject(data) {
  return request({
    url: `/xm/project/info/stopProject`,
    method: 'post',
    data,
    jy: true
  })
}

/************************************* 数据统计 *************************************** */

// 项目实施进度
export function getProcess(params) {
  return request({
    url: `/xm/project/data/analysis/period`,
    method: 'get',
    params,
    jy: true
  })
}

// 项目经费分布
export function getFunds(params) {
  return request({
    url: `/xm/project/data/analysis/funds`,
    method: 'get',
    params,
    jy: true
  })
}

// 项目变更次数
export function getChangeCount(params) {
  return request({
    url: `/xm/project/data/analysis/change`,
    method: 'get',
    params,
    jy: true
  })
}

// 年度项目数量统计
export function getProjectCount(params) {
  return request({
    url: `/xm/project/data/analysis/projectNum`,
    method: 'get',
    params,
    jy: true
  })
}
